package Logic;


import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* This is a decimal roundup class.
*
* The class has only one method. See the method "round" for details.
*/

public class RoundMath {
	/** 
	 * This method is used to round a given number to the amount of decimals specified in the places parameter.
	* @param places
	* The amount of decimals to attach to the rounded number.
	* @param value
	* The number to round.
	* @throws
	* IllegalArgumentException if the the user tries to use a negative value for the places parameter.    
	* @returns
	* The rounded result, as a double.
	*/
	public static double round(double value, int places) {
	    if (places < 0) throw new IllegalArgumentException();

	    BigDecimal bd = new BigDecimal(value);
	    bd = bd.setScale(places, RoundingMode.HALF_UP);
	    return bd.doubleValue();
	}
}